import React from 'react';

import Constants from '../../common/Constants';
import ResponseConstants from '../../common/ResponseConstants';
import BaseAction from '../common/BaseAction';

export default class RequestCommentListAction extends BaseAction {
  constructor() {
    super();
  }

  call(caller, data) {
    this._baseCall(caller, data);
    this.caller.setState({
      viewStatus: 2,
    })
  }

  finish(data, isSucceed, response) {
    if(isSucceed) {
      this.caller.setState({
        viewStatus: 3,
        data: data,
        isResponeUpdate: true,
      })
    }
    else if (data) {
      if(data.status == ResponseConstants.status_unauthorized) {
        this._dealUnauthorized(this.caller);
      }
      else {
        this.caller.setState({viewStatus: data.status})
      }
    }
    else {
      this.caller.setState({viewStatus: 400})
    }
  }
}
